package com.woniuxy.carlife.carlifeuserweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifeuserweb.entity.Region;
import com.woniuxy.carlife.carlifeuserweb.mapper.RegionMapper;
import com.woniuxy.carlife.carlifeuserweb.service.RegionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:RegionServiceImpl
 * @Description:
 * @date 2021/4/6 20:02
 **/

@Service
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {

    @Resource
    RegionMapper regionMapper;

    /*
     * 功能描述〈根据市id查询地区〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/12 15:36
     * @throws
     */

    @Override
    public List<Region> findRegionByCityId(Integer cityId)  {
        QueryWrapper<Region> regionQueryWrapper = new QueryWrapper<>();
        regionQueryWrapper.eq("city_id",cityId);
        List<Region> regions = regionMapper.selectList(regionQueryWrapper);
        return regions==null?null:regions;
    }
}
